package map;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class Main {
    static List<List<Integer>> result = new ArrayList<>();
    static List<Integer> path = new ArrayList<>();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        //邻接矩阵写法
//        int[][] nextTable = new int[N + 1][N + 1];
//        for (int i = 0; i < M; i++) {
//            int a = sc.nextInt();
//            int b = sc.nextInt();
//            nextTable[a][b] = 1;
//        }
        //邻接表写法
        List<List<Integer>> map = new ArrayList<>(N + 1);
        for (int i = 0; i <= N; i++) {
            map.add((new ArrayList<>()));
        }
        for (int i = 0; i < M; i++) {
            int s = sc.nextInt();
            int t = sc.nextInt();
            // 使用邻接表表示 s -> t 是相连的
            map.get(s).add(t);
        }
        path.add(1);
        //邻接矩阵
//        dfsArray(nextTable, 1, N);
        //邻接表
        dfsList(map, 1, N);

        if (result.isEmpty()){
            System.out.println(-1);
        }
        for (List<Integer> path : result) {
            for (int i = 0; i < path.size() - 1; i++) {
                System.out.print(path.get(i) + " ");
            }
            System.out.println(path.get(path.size() - 1));
        }
    }
    public static void dfsArray(int[][] map, int x, int n){
        if (x == n){
            result.add(new ArrayList<>(path));
            return;
        }
        for (int i = 1; i <= n; i++) {
            if (map[x][i] == 1){
                path.add(i);
                dfsArray(map, i, n);
                path.remove(path.size() - 1);
            }
        }
    }
    public static void dfsList(List<List<Integer>> map, int x, int n){
        if (x == n){
            result.add(new ArrayList<>(path));
            return;
        }
        for (int i : map.get(x)) {
            path.add(i);
            dfsList(map, i, n);
            path.remove(path.size() - 1);
        }
    }
}
